const express = require('express');
const videoController = require('./../controllers/videoController');
const authController = require('./../controllers/authController');
const videoReviewRouter = require('./../routes/videoReviewRoutes');
const danmuRouter = require('./../routes/danmuRoutes');
const router = express.Router({ mergeParams: true });
// '/users/:userId(234fad4)/videos/94887fda',
// P0ST /users/234fad4/videos
// GET /users/234fad4/videos
//GET /users/234fad4/videos/94887fda
router.use('/:videoId/danmus', danmuRouter);
router.use('/:videoId/videoReviews', videoReviewRouter);
router.use(authController.protect);
router.route('/').get(videoController.getAllVideos).post(
  videoController.setVideoUserId,
  // authController.restrictTo('user'),
  videoController.createVideo
);
router.route('/:videoId/addPlayCount').post(videoController.addPlayCount);
router.route('/myVideo').get(videoController.getOweVideos);
router
  .route('/:id')
  .get(videoController.getVideo)
  .delete(videoController.deleteVideo);
module.exports = router;
